Logo Search packages:      
Sourcecode: codeblocks version File versions  Download package

void wxPdfDocument::OutIndirectObject ( wxPdfIndirectObject object ) [protected]

Add an indirect object to the document.

TODO: support for radio button groups

Definition at line 155 of file pdfform.cpp.

References Double2String(), wxPdfPushButton::GetAction(), wxPdfAnnotationWidget::GetBackgroundColor(), wxPdfAnnotationWidget::GetBorderColor(), wxPdfAnnotationWidget::GetBorderStyle(), wxPdfAnnotationWidget::GetBorderWidth(), wxPdfPushButton::GetCaption(), wxPdfTextField::GetFontIndex(), wxPdfPushButton::GetFontIndex(), wxPdfComboBox::GetFontIndex(), wxPdfTextField::GetFontSize(), wxPdfPushButton::GetFontSize(), wxPdfComboBox::GetFontSize(), wxPdfIndirectObject::GetGenerationId(), wxPdfAnnotationObject::GetHeight(), wxPdfRadioButton::GetIndex(), wxPdfRadioGroup::GetKids(), wxPdfTextField::GetMultiLine(), wxPdfAnnotationWidget::GetName(), wxPdfRadioGroup::GetName(), wxPdfIndirectObject::GetObjectId(), wxPdfRadioButton::GetParent(), wxPdfAnnotationWidget::GetTextColor(), wxPdfIndirectObject::GetType(), wxPdfTextField::GetValue(), wxPdfComboBox::GetValue(), wxPdfCheckBox::GetValue(), wxPdfAnnotationObject::GetWidth(), wxPdfAnnotationObject::GetX(), wxPdfAnnotationObject::GetY(), m_buffer, m_h, m_k, m_offsets, m_zapfdingbats, Out(), OutAscii(), OutAsciiTextstring(), and OutTextstring().

Referenced by PutFormFields().

{
  int objectId = object->GetObjectId();
  int generationId = object->GetGenerationId();
  if (m_offsets->count(objectId-1) == 0)
  {
    (*m_offsets)[objectId-1] = m_buffer.TellO();
    OutAscii(wxString::Format(_T("%d %d obj"), objectId, generationId));
    switch (object->GetType())
    {
      case wxPDF_OBJECT_RADIOGROUP:
        {
          wxPdfRadioGroup* obj = static_cast<wxPdfRadioGroup*>(object);
/// TODO: support for radio button groups
// Currently radio button groups do not function
          Out("<<");
          Out("/FT /Btn");
          OutAscii(wxString::Format(_T("/Ff %d"), (1 << 14) | (1 << 15)));
//          Out("/F 4");
          Out("/T ", false);
          OutAsciiTextstring(obj->GetName());
#if 0
          OutAscii(wxString(_T("/BS << /W ") + 
                   Double2String(obj->GetBorderWidth() +
                   wxString(_T("/S/")) + obj->GetBorderStyle() + 
                   wxString(_T(">>")));
#endif
//          OutAscii(wxString(_T("/MK <</BC [")) + obj->GetBorder() +
//                   wxString(_T("]/BG [")) + obj->GetBackground() + wxString(_T("] /CA ")), false);
//          OutAsciiTextstring(wxString(_T("4")), false);
//          Out(">>");
          Out("/DR 2 0 R");
          Out("/DA ", false);
//          OutAsciiTextstring(wxString::Format(_T("/F%d 9 Tf "), m_zapfdingbats) + obj->GetTextColor());
//          Out("/AP <</N <</Yes <<>>>> >>");
//          Out("/AS /Off");
          Out("/V /V1");
          Out("/Kids [", false);
          size_t j;
          wxPdfRadioButton* radio;
          wxArrayPtrVoid kids = obj->GetKids();
          for (j = 0; j < kids.GetCount(); j++)
          {
            radio = static_cast<wxPdfRadioButton*>(kids[j]);
            OutAscii(wxString::Format(_T("%d %d R "), radio->GetObjectId(), radio->GetGenerationId()), false);
          }
          Out("]");
          Out(">>");
          Out("endobj");
          for (j = 0; j < kids.GetCount(); j++)
          {
            wxPdfRadioButton* radio = static_cast<wxPdfRadioButton*>(kids[j]);
            OutIndirectObject(radio);
          }
        }
        break;

      case wxPDF_OBJECT_WIDGET_CHECKBOX:
        {
          wxPdfCheckBox* obj = static_cast<wxPdfCheckBox*>(object);
          Out("<<");
          Out("/Type /Annot");
          Out("/Subtype /Widget");
          OutAscii(wxString(_T("/Rect [")) +
                   Double2String(obj->GetX()*m_k,2) + wxString(_T(" ")) +
                   Double2String((m_h - obj->GetY())*m_k,2) +  wxString(_T(" ")) +
                   Double2String((obj->GetX() + obj->GetWidth())*m_k,2) +  wxString(_T(" ")) +
                   Double2String((m_h - obj->GetY() - obj->GetHeight())*m_k,2) + wxString(_T("]")));
          Out("/FT /Btn");
          Out("/Ff 0");
          Out("/F 4");
          Out("/T ", false);
          OutAsciiTextstring(obj->GetName());
          // Border style
          OutAscii(wxString(_T("/BS << /W ")) + 
                   Double2String(obj->GetBorderWidth(), 2) +
                   wxString(_T("/S/")) + obj->GetBorderStyle() + 
                   wxString(_T(">>")));
          OutAscii(wxString(_T("/MK <</BC [")) + obj->GetBorderColor() +
                   wxString(_T("]/BG [")) + obj->GetBackgroundColor() + wxString(_T("] /CA ")), false);
          OutAsciiTextstring(wxString(_T("4")), false);
          Out(">>");
          Out("/DR 2 0 R");
          Out("/DA ", false);
          OutAsciiTextstring(wxString::Format(_T("/F%d 9 Tf "), m_zapfdingbats) + obj->GetTextColor());
          Out("/AP <</N <</Yes <<>>>> >>");
          Out("/AS /Off");
          if (obj->GetValue())
          {
            Out("/DV /Yes");
            Out("/V /Yes");
          }
          else
          {
            Out("/DV /Off");
            Out("/V /Off");
          }
          Out(">>");
          Out("endobj");
        }
        break;

      case wxPDF_OBJECT_WIDGET_COMBOBOX:
        {
          wxPdfComboBox* obj = static_cast<wxPdfComboBox*>(object);
          Out("<<");
          Out("/Type /Annot");
          Out("/Subtype /Widget");
          OutAscii(wxString(_T("/Rect [")) +
                   Double2String(obj->GetX()*m_k,2) + wxString(_T(" ")) +
                   Double2String((m_h - obj->GetY())*m_k,2) +  wxString(_T(" ")) +
                   Double2String((obj->GetX() + obj->GetWidth())*m_k,2) +  wxString(_T(" ")) +
                   Double2String((m_h - obj->GetY() - obj->GetHeight())*m_k,2) + wxString(_T("]")));
          Out("/FT /Ch");
          Out("/Ff 67764224");
          Out("/F 4");
          Out("/T ", false);
          OutAsciiTextstring(obj->GetName());
          OutAscii(wxString(_T("/MK <</BC [")) + obj->GetBorderColor() +
                   wxString(_T("]/BG [")) + obj->GetBackgroundColor() + wxString(_T("]>>")));
          // Border style
          OutAscii(wxString(_T("/BS << /W ")) + 
                   Double2String(obj->GetBorderWidth(), 2) +
                   wxString(_T("/S/")) + obj->GetBorderStyle() + 
                   wxString(_T(">>")));
          Out("/DR 2 0 R");
          Out("/DA ", false);
          OutAsciiTextstring(wxString::Format(_T("/F%d "), obj->GetFontIndex()) +
                             Double2String(obj->GetFontSize(),2) +
                             wxString(_T(" Tf ")) + obj->GetTextColor()); 
          wxArrayString options = obj->GetValue();
          Out("/DV ", false);
          OutTextstring(options[0]);
          Out("/V ", false);
          OutTextstring(options[0]);
// Option list alternative (transfer value, display value)
//   /Op t [ [(1)(Socks)][(2)(Shoes)] [(3)(Pants)][(4)(Shirt)][(5)(Tie)][(6)(Belt)][(7)(Shorts)]]
//
          Out("/Opt [", false);
          size_t j;
          for (j = 0; j < options.GetCount(); j++)
          {
            OutTextstring(options[j], false);
          }
          Out("]");
          Out(">>");
          Out("endobj");
        }
        break;

      case wxPDF_OBJECT_WIDGET_PUSHBUTTON:
        {
          wxPdfPushButton* obj = static_cast<wxPdfPushButton*>(object);
          Out("<<");
          Out("/Type /Annot");
          Out("/Subtype /Widget");
          OutAscii(wxString(_T("/Rect [")) +
                   Double2String(obj->GetX()*m_k,2) + wxString(_T(" ")) +
                   Double2String((m_h - obj->GetY())*m_k,2) +  wxString(_T(" ")) +
                   Double2String((obj->GetX() + obj->GetWidth())*m_k,2) +  wxString(_T(" ")) +
                   Double2String((m_h - obj->GetY() - obj->GetHeight())*m_k,2) + wxString(_T("]")));
          Out("/FT /Btn");
          Out("/Ff 65536"); // (1 << 16),
          Out("/F 4");
// Highlight button
//        Out("/H");
          Out("/T ", false);
          OutAsciiTextstring(obj->GetName());
          Out("/BS << /W 1 /S /B >>");
          OutAscii(wxString(_T("/MK <</BC [")) + obj->GetBorderColor() +
                   wxString(_T("]/BG [")) + obj->GetBackgroundColor() + 
                   wxString(_T("] /CA ")), false);
          OutTextstring(obj->GetCaption(), false);
          Out(">>");
          Out("/DR 2 0 R");
          Out("/DA ", false);
          OutAsciiTextstring(wxString::Format(_T("/F%d "), obj->GetFontIndex()) +
                             Double2String(obj->GetFontSize(),2) + 
                             wxString(_T(" Tf ")) + obj->GetTextColor()); 
          Out("/A <</S /JavaScript /JS", false);
          OutTextstring(obj->GetAction());
          Out(">>");
          Out(">>");
          Out("endobj");
        }
        break;

      case wxPDF_OBJECT_WIDGET_RADIOBUTTON:
        {
          wxPdfRadioButton* obj = static_cast<wxPdfRadioButton*>(object);
          Out("<<");
          Out("/Type /Annot");
          Out("/Subtype /Widget");
          OutAscii(wxString(_T("/Rect [")) +
                   Double2String(obj->GetX()*m_k,2) + wxString(_T(" ")) +
                   Double2String((m_h - obj->GetY())*m_k,2) +  wxString(_T(" ")) +
                   Double2String((obj->GetX() + obj->GetWidth())*m_k,2) +  wxString(_T(" ")) +
                   Double2String((m_h - obj->GetY() - obj->GetHeight())*m_k,2) + wxString(_T("]")));
          Out("/FT /Btn");
          Out("/Ff 49152");
          Out("/F 4");
          wxPdfRadioGroup* parent = obj->GetParent();
#if 0
// TODO: integrate radio button groups into PDF document
          OutAscii(wxString::Format(_T("/Parent [%d %d R]"), parent->GetObjectId(), parent->GetGenerationId()));
//          Out("/P ??? 0 R /H /T ");
#endif
          Out("/T ", false);
          OutAsciiTextstring(parent->GetName());
          Out("/AS /Off");
          OutAscii(wxString(_T("/MK <</BC [")) + obj->GetBorderColor() +
                   wxString(_T("]/BG [")) + obj->GetBackgroundColor() + 
                   wxString(_T("] /CA ")), false);
          OutAsciiTextstring(wxString(_T("l")), false);
          Out(">>");
          // Border style
          OutAscii(wxString(_T("/BS << /W ")) + 
                   Double2String(obj->GetBorderWidth(), 2) +
                   wxString(_T("/S/")) + obj->GetBorderStyle() + 
                   wxString(_T(">>")));
          Out("/DR 2 0 R");
          Out("/DA ", false);
          OutAsciiTextstring(wxString::Format(_T("/F%d 9 Tf "), m_zapfdingbats) + obj->GetTextColor());
          OutAscii(wxString::Format(_T("/AP <</N <</V%d <<>> >> >>"), obj->GetIndex()));
          // Set first button in group as selected
          if (obj->GetIndex() == 1)
          {
            OutAscii(wxString::Format(_T("/V /V%d"), obj->GetIndex()));
          }
          Out(">>");
          Out("endobj");
        }
        break;

      case wxPDF_OBJECT_WIDGET_TEXTFIELD:
        {
          wxPdfTextField* obj = static_cast<wxPdfTextField*>(object);
          Out("<<");
          Out("/Type /Annot");
          Out("/Subtype /Widget");
          OutAscii(wxString(_T("/Rect [")) +
                   Double2String(obj->GetX()*m_k,2) + wxString(_T(" ")) +
                   Double2String((m_h - obj->GetY())*m_k,2) +  wxString(_T(" ")) +
                   Double2String((obj->GetX() + obj->GetWidth())*m_k,2) +  wxString(_T(" ")) +
                   Double2String((m_h - obj->GetY() - obj->GetHeight())*m_k,2) + wxString(_T("]")));
          Out("/FT /Tx");
          if (obj->GetMultiLine())
          {
            Out("/Ff 4096");
          }
          Out("/F 4");
          Out("/T ", false);
          OutAsciiTextstring(obj->GetName());
          Out("/V ", false);
          OutTextstring(obj->GetValue()); // Current value
          Out("/DV ", false);
          OutTextstring(obj->GetValue()); // Default value
// Maximal length of text input
//          OutAscii(wxString::Format(_T("/MaxLen %d"), obj->GetMaxLength());
          OutAscii(wxString(_T("/MK <</BC [")) + obj->GetBorderColor() +
                   wxString(_T("]/BG [")) + obj->GetBackgroundColor() + wxString(_T("]>>")));
          // Border style
          OutAscii(wxString(_T("/BS << /W ")) + 
                   Double2String(obj->GetBorderWidth(), 2) +
                   wxString(_T("/S/")) + obj->GetBorderStyle() + 
                   wxString(_T(">>")));
          Out("/DR 2 0 R");
          Out("/DA ", false);
          OutAsciiTextstring(wxString::Format(_T("/F%d "), obj->GetFontIndex()) +
                             Double2String(obj->GetFontSize(),2) + 
                             wxString(_T(" Tf ")) + obj->GetTextColor()); 
          Out(">>");
          Out("endobj");
        }
        break;

      case wxPDF_OBJECT_WIDGET:
      case wxPDF_OBJECT_ANNOTATION:
      case wxPDF_OBJECT_INDIRECT:
      default:
        Out("endobj");
        break;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index