Exemplo n.º 1
0
bool CWizDatabase::CreateDocumentAndInit(const CString& strHtml, \
        const CString& strHtmlUrl, \
        int nFlags, \
        const CString& strTitle, \
        const CString& strName, \
        const CString& strLocation, \
        const CString& strURL, \
        WIZDOCUMENTDATA& data)
{
    bool bRet = false;
    try
    {
        BeginUpdate();

        data.strKbGUID = kbGUID();
        bRet = CreateDocument(strTitle, strName, strLocation, strHtmlUrl, data);
        if (bRet)
        {
            bRet = UpdateDocumentData(data, strHtml, strURL, nFlags);

            Q_EMIT documentCreated(data);
        }
    }
    catch (...)
    {

    }

    EndUpdate();

    return bRet;
}
Exemplo n.º 2
0
BOOL CmyWord::Create()  
{  
    if (FALSE == CreateDocuments())   
    {  
        return FALSE;  
    }  
    return CreateDocument();  
}  
Exemplo n.º 3
0
NS_IMETHODIMP
DOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
                                  const nsAString& aQualifiedName,
                                  nsIDOMDocumentType* aDoctype,
                                  nsIDOMDocument** aReturn)
{
  nsCOMPtr<nsIDocument> document;
  return CreateDocument(aNamespaceURI, aQualifiedName, aDoctype,
                        getter_AddRefs(document), aReturn);
}
Exemplo n.º 4
0
already_AddRefed<nsIDocument>
DOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
                                  const nsAString& aQualifiedName,
                                  nsIDOMDocumentType* aDoctype,
                                  ErrorResult& aRv)
{
  nsCOMPtr<nsIDocument> document;
  nsCOMPtr<nsIDOMDocument> domDocument;
  aRv = CreateDocument(aNamespaceURI, aQualifiedName, aDoctype,
                       getter_AddRefs(document), getter_AddRefs(domDocument));
  return document.forget();
}
Exemplo n.º 5
0
void
DviDoc::Reread ()
{
  MIKTEX_ASSERT (! isPrintContext);
  Dvi * pDvi = this->pDvi;
  this->pDvi = 0;
  fileStatus = DVIFILE_NOT_LOADED;
  if (pDvi != 0)
    {
      delete pDvi;
    }
  CreateDocument (TU_(GetPathName()));
}
Exemplo n.º 6
0
void CPicturePreview::NewGraphicPreview(LPCSTR pszName, LPCSTR pszFriendlyName /*=NULL*/, LPBITMAPINFO pDib /*=NULL*/)
{
	// If we have no preview window, we have nothing.
	if (GetPreviewWnd() == NULL)
	{
		return;
	}

	// Erase the preview area.
	ErasePreview();

	// Make sure we have a document.
	if (!CreateDocument())
	{
		return;
	}

	//if (lstrcmp(pszName, "") != 0)
	//{
		if (pszName != NULL || pDib != NULL) //&& Util::FileExists(pszName))
		{
			GRAPHIC_CREATE_STRUCT* pGCS = m_pDoc->get_gcs();

			pGCS->proof = FALSE;

			if (pDib != NULL)
			{
				// We have DIB to construct from.
				pGCS->m_pTempDIB = pDib;
				pszFriendlyName = "";
			}

			m_pDoc->SetImportPictureName(pszName, pszFriendlyName);

			// Create the chosen picture.
			m_pDoc->create_chosen_picture();

			// Check to see if the object loaded was an animated GIF image.
			CheckForAnimatedGIF();

			// We want to compute the enclosing bound for the objects.
			m_fEncloseObjects = TRUE;

			// And size the preview window.
			SizeDocPreview();

			// Set the description.
			SetDescription(pszName, pszFriendlyName);
		}
	//}
}
Exemplo n.º 7
0
void ezQtEditorApp::GuiCreateOrOpenDocument(bool bCreate)
{
  const ezString sAllFilters = BuildDocumentTypeFileFilter(bCreate);

  if (sAllFilters.IsEmpty())
  {
    ezQtUiServices::MessageBoxInformation("No file types are currently known. Load plugins to add file types.");
    return;
  }

  static QString sSelectedExt;
  const QString sDir = QString::fromUtf8(m_sLastDocumentFolder.GetData());

  ezString sFile;

  if (bCreate)
    sFile = QFileDialog::getSaveFileName(QApplication::activeWindow(), QLatin1String("Create Document"), sDir,
                                         QString::fromUtf8(sAllFilters.GetData()), &sSelectedExt, QFileDialog::Option::DontResolveSymlinks)
                .toUtf8()
                .data();
  else
    sFile = QFileDialog::getOpenFileName(QApplication::activeWindow(), QLatin1String("Open Document"), sDir,
                                         QString::fromUtf8(sAllFilters.GetData()), &sSelectedExt, QFileDialog::Option::DontResolveSymlinks)
                .toUtf8()
                .data();

  if (sFile.IsEmpty())
    return;

  m_sLastDocumentFolder = ezPathUtils::GetFileDirectory(sFile);

  const ezDocumentTypeDescriptor* pTypeDesc = nullptr;
  if (ezDocumentManager::FindDocumentTypeFromPath(sFile, bCreate, pTypeDesc).Succeeded())
  {
    sSelectedExt = pTypeDesc->m_sDocumentTypeName;
  }

  if (bCreate)
    CreateDocument(sFile, ezDocumentFlags::AddToRecentFilesList | ezDocumentFlags::RequestWindow);
  else
    OpenDocument(sFile, ezDocumentFlags::AddToRecentFilesList | ezDocumentFlags::RequestWindow);
}
Exemplo n.º 8
0
void FB_Frame::OnOpen( wxCommandEvent& event ) {
    wxFileDialog dlg (this,
        _T("Load file"),
        _T(""),
        _T(".bas"),
        _T("FBFiles (*.bas)|*.bas|FBHeader files(*.bi)|*.bi|HTML files (*.html)|*.html|All file(*)|*.*|"),
    wxFILE_MUST_EXIST | wxCHANGE_DIR | wxMULTIPLE);
    
    if (dlg.ShowModal() != wxID_OK) return;
    
    wxArrayString File;
    dlg.GetPaths(File);
    
    for(int i = 0; i < static_cast<int>( File.Count() ); i++ ) {
        m_Config->m_FileHistory->AddFileToHistory( File[i] );
        CreateDocument( File[i] );
    }
    
    return;
}
Exemplo n.º 9
0
void
DviDoc::BeginDviPrinting (/*[in]*/ const CDC * pPrinterDC)
{
  UNUSED_ALWAYS (pPrinterDC);
  MIKTEX_ASSERT (! isPrintContext);
  MIKTEX_ASSERT (pDviSave == 0);
  MIKTEX_ASSERT (pDvi != 0);
  isPrintContext = true;
  pDviSave = pDvi;
  pDvi = 0;
  try
    {
      CreateDocument (TU_(GetPathName()));
    }
  catch (const exception &)
    {
      this->pDvi = pDviSave;
      pDviSave = 0;
      isPrintContext = false;
      throw;
    }
}
Exemplo n.º 10
0
BOOL
DviDoc::OnOpenDocument (/*[in]*/ LPCTSTR lpszPathName) 
{
  try
    {
      MIKTEX_ASSERT (pDvi == 0);
      MIKTEX_ASSERT (pDviSave == 0);
      MIKTEX_ASSERT (! isPrintContext);
      CreateDocument (TU_(lpszPathName));
      return (TRUE);
    }
  catch (const MiKTeXException & e)
    {
      ErrorDialog::DoModal (0, e);
      return (FALSE);
    }
  catch (const exception & e)
    {
      ErrorDialog::DoModal (0, e);
      return (FALSE);
    }
}
Exemplo n.º 11
0
NS_IMETHODIMP
nsContentDLF::CreateInstance(const char* aCommand,
                             nsIChannel* aChannel,
                             nsILoadGroup* aLoadGroup,
                             const char* aContentType, 
                             nsISupports* aContainer,
                             nsISupports* aExtraInfo,
                             nsIStreamListener** aDocListener,
                             nsIContentViewer** aDocViewer)
{
  EnsureUAStyleSheet();

  // Are we viewing source?
#ifdef MOZ_VIEW_SOURCE
  nsCOMPtr<nsIViewSourceChannel> viewSourceChannel = do_QueryInterface(aChannel);
  if (viewSourceChannel)
  {
    aCommand = "view-source";

    // The parser freaks out when it sees the content-type that a
    // view-source channel normally returns.  Get the actual content
    // type of the data.  If it's known, use it; otherwise use
    // text/plain.
    nsCAutoString type;
    viewSourceChannel->GetOriginalContentType(type);
    PRBool knownType = PR_FALSE;
    PRInt32 typeIndex;
    for (typeIndex = 0; gHTMLTypes[typeIndex] && !knownType; ++typeIndex) {
      if (type.Equals(gHTMLTypes[typeIndex]) &&
          !type.EqualsLiteral("application/x-view-source")) {
        knownType = PR_TRUE;
      }
    }

    for (typeIndex = 0; gXMLTypes[typeIndex] && !knownType; ++typeIndex) {
      if (type.Equals(gXMLTypes[typeIndex])) {
        knownType = PR_TRUE;
      }
    }

#ifdef MOZ_SVG
    if (NS_SVGEnabled()) {
      for (typeIndex = 0; gSVGTypes[typeIndex] && !knownType; ++typeIndex) {
        if (type.Equals(gSVGTypes[typeIndex])) {
          knownType = PR_TRUE;
        }
      }
    }
#endif // MOZ_SVG

    for (typeIndex = 0; gXULTypes[typeIndex] && !knownType; ++typeIndex) {
      if (type.Equals(gXULTypes[typeIndex])) {
        knownType = PR_TRUE;
      }
    }

    if (knownType) {
      viewSourceChannel->SetContentType(type);
    } else {
      viewSourceChannel->SetContentType(NS_LITERAL_CSTRING("text/plain"));
    }
  } else if (0 == PL_strcmp("application/x-view-source", aContentType)) {
    aChannel->SetContentType(NS_LITERAL_CSTRING("text/plain"));
    aContentType = "text/plain";
  }
#endif
  // Try html
  int typeIndex=0;
  while(gHTMLTypes[typeIndex]) {
    if (0 == PL_strcmp(gHTMLTypes[typeIndex++], aContentType)) {
      return CreateDocument(aCommand, 
                            aChannel, aLoadGroup,
                            aContainer, kHTMLDocumentCID,
                            aDocListener, aDocViewer);
    }
  }

  // Try XML
  typeIndex = 0;
  while(gXMLTypes[typeIndex]) {
    if (0== PL_strcmp(gXMLTypes[typeIndex++], aContentType)) {
      return CreateDocument(aCommand, 
                            aChannel, aLoadGroup,
                            aContainer, kXMLDocumentCID,
                            aDocListener, aDocViewer);
    }
  }

#ifdef MOZ_SVG
  if (NS_SVGEnabled()) {
    // Try SVG
    typeIndex = 0;
    while(gSVGTypes[typeIndex]) {
      if (!PL_strcmp(gSVGTypes[typeIndex++], aContentType)) {
        return CreateDocument(aCommand,
                              aChannel, aLoadGroup,
                              aContainer, kSVGDocumentCID,
                              aDocListener, aDocViewer);
      }
    }
  }
#endif

  // Try XUL
  typeIndex = 0;
  while (gXULTypes[typeIndex]) {
    if (0 == PL_strcmp(gXULTypes[typeIndex++], aContentType)) {
      return CreateXULDocument(aCommand, 
                               aChannel, aLoadGroup,
                               aContentType, aContainer,
                               aExtraInfo, aDocListener, aDocViewer);
    }
  }

  // Try image types
  nsCOMPtr<imgILoader> loader(do_GetService("@mozilla.org/image/loader;1"));
  PRBool isReg = PR_FALSE;
  loader->SupportImageWithMimeType(aContentType, &isReg);
  if (isReg) {
    return CreateDocument(aCommand, 
                          aChannel, aLoadGroup,
                          aContainer, kImageDocumentCID,
                          aDocListener, aDocViewer);
  }

  nsCOMPtr<nsIPluginHost> ph (do_GetService(kPluginManagerCID));
  if(ph && NS_SUCCEEDED(ph->IsPluginEnabledForType(aContentType))) {
    return CreateDocument(aCommand,
                          aChannel, aLoadGroup,
                          aContainer, kPluginDocumentCID,
                          aDocListener, aDocViewer);
  }


  // If we get here, then we weren't able to create anything. Sorry!
  return NS_ERROR_FAILURE;
}
Exemplo n.º 12
0
NS_IMETHODIMP
nsContentDLF::CreateInstance(const char* aCommand,
                             nsIChannel* aChannel,
                             nsILoadGroup* aLoadGroup,
                             const char* aContentType, 
                             nsISupports* aContainer,
                             nsISupports* aExtraInfo,
                             nsIStreamListener** aDocListener,
                             nsIContentViewer** aDocViewer)
{
#ifdef NS_FUNCTION_TIMER
  nsCAutoString channelURL__("N/A");
  nsCOMPtr<nsIURI> url__;
  if (aChannel && NS_SUCCEEDED(aChannel->GetURI(getter_AddRefs(url__)))) {
    url__->GetSpec(channelURL__);
  }
  NS_TIME_FUNCTION_FMT("%s (line %d) (url: %s)", MOZ_FUNCTION_NAME,
                       __LINE__, channelURL__.get());
#endif

  // Declare "type" here.  This is because although the variable itself only
  // needs limited scope, we need to use the raw string memory -- as returned
  // by "type.get()" farther down in the function.
  nsCAutoString type;

  // Are we viewing source?
  nsCOMPtr<nsIViewSourceChannel> viewSourceChannel = do_QueryInterface(aChannel);
  if (viewSourceChannel)
  {
    aCommand = "view-source";

    // The parser freaks out when it sees the content-type that a
    // view-source channel normally returns.  Get the actual content
    // type of the data.  If it's known, use it; otherwise use
    // text/plain.
    viewSourceChannel->GetOriginalContentType(type);
    bool knownType = false;
    PRInt32 typeIndex;
    for (typeIndex = 0; gHTMLTypes[typeIndex] && !knownType; ++typeIndex) {
      if (type.Equals(gHTMLTypes[typeIndex]) &&
          !type.EqualsLiteral(VIEWSOURCE_CONTENT_TYPE)) {
        knownType = PR_TRUE;
      }
    }

    for (typeIndex = 0; gXMLTypes[typeIndex] && !knownType; ++typeIndex) {
      if (type.Equals(gXMLTypes[typeIndex])) {
        knownType = PR_TRUE;
      }
    }

    for (typeIndex = 0; gSVGTypes[typeIndex] && !knownType; ++typeIndex) {
      if (type.Equals(gSVGTypes[typeIndex])) {
        knownType = PR_TRUE;
      }
    }

    for (typeIndex = 0; gXULTypes[typeIndex] && !knownType; ++typeIndex) {
      if (type.Equals(gXULTypes[typeIndex])) {
        knownType = PR_TRUE;
      }
    }

    if (knownType) {
      viewSourceChannel->SetContentType(type);
    } else if (IsImageContentType(type.get())) {
      // If it's an image, we want to display it the same way we normally would.
      // Also note the lifetime of "type" allows us to safely use "get()" here.
      aContentType = type.get();
    } else {
      viewSourceChannel->SetContentType(NS_LITERAL_CSTRING(TEXT_PLAIN));
    }
  } else if (0 == PL_strcmp(VIEWSOURCE_CONTENT_TYPE, aContentType)) {
    aChannel->SetContentType(NS_LITERAL_CSTRING(TEXT_PLAIN));
    aContentType = TEXT_PLAIN;
  }
  // Try html
  int typeIndex=0;
  while(gHTMLTypes[typeIndex]) {
    if (0 == PL_strcmp(gHTMLTypes[typeIndex++], aContentType)) {
      return CreateDocument(aCommand, 
                            aChannel, aLoadGroup,
                            aContainer, kHTMLDocumentCID,
                            aDocListener, aDocViewer);
    }
  }

  // Try XML
  typeIndex = 0;
  while(gXMLTypes[typeIndex]) {
    if (0== PL_strcmp(gXMLTypes[typeIndex++], aContentType)) {
      return CreateDocument(aCommand, 
                            aChannel, aLoadGroup,
                            aContainer, kXMLDocumentCID,
                            aDocListener, aDocViewer);
    }
  }

  // Try SVG
  typeIndex = 0;
  while(gSVGTypes[typeIndex]) {
    if (!PL_strcmp(gSVGTypes[typeIndex++], aContentType)) {
      return CreateDocument(aCommand,
                            aChannel, aLoadGroup,
                            aContainer, kSVGDocumentCID,
                            aDocListener, aDocViewer);
    }
  }

  // Try XUL
  typeIndex = 0;
  while (gXULTypes[typeIndex]) {
    if (0 == PL_strcmp(gXULTypes[typeIndex++], aContentType)) {
      if (!MayUseXULXBL(aChannel)) {
        return NS_ERROR_REMOTE_XUL;
      }

      return CreateXULDocument(aCommand,
                               aChannel, aLoadGroup,
                               aContentType, aContainer,
                               aExtraInfo, aDocListener, aDocViewer);
    }
  }

#ifdef MOZ_MEDIA
  if (nsHTMLMediaElement::ShouldHandleMediaType(aContentType)) {
    return CreateDocument(aCommand, 
                          aChannel, aLoadGroup,
                          aContainer, kVideoDocumentCID,
                          aDocListener, aDocViewer);
  }  
#endif

  // Try image types
  if (IsImageContentType(aContentType)) {
    return CreateDocument(aCommand, 
                          aChannel, aLoadGroup,
                          aContainer, kImageDocumentCID,
                          aDocListener, aDocViewer);
  }

  nsCOMPtr<nsIPluginHost> pluginHostCOM(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
  nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
  if(pluginHost &&
     NS_SUCCEEDED(pluginHost->IsPluginEnabledForType(aContentType))) {
    return CreateDocument(aCommand,
                          aChannel, aLoadGroup,
                          aContainer, kPluginDocumentCID,
                          aDocListener, aDocViewer);
  }

  // If we get here, then we weren't able to create anything. Sorry!
  return NS_ERROR_FAILURE;
}
//-----------------------------------------------------------------------------------------------------------------------------------
void LevelDesignScreenData::SerializeLevel(const std::list<LevelDesignObject*>& levelObjects)
{
  // Create here for non-const and also we are serializing to a file so create feels more appropriate anyway
  tinyxml2::XMLDocument* xmlDocument = CreateDocument();
  
  tinyxml2::XMLDeclaration* declaration = xmlDocument->NewDeclaration();
  xmlDocument->InsertFirstChild(declaration);

  tinyxml2::XMLElement* rootElement = xmlDocument->NewElement("Root");
  xmlDocument->InsertAfterChild(declaration, rootElement);

  tinyxml2::XMLElement* displayNameElement = xmlDocument->NewElement("DisplayName");
  rootElement->InsertFirstChild(displayNameElement);

  tinyxml2::XMLElement* backgroundTextureAsset = xmlDocument->NewElement("BackgroundTextureAsset");
  backgroundTextureAsset->SetText("EmptyBackground.png");
  rootElement->InsertAfterChild(displayNameElement, backgroundTextureAsset);

  tinyxml2::XMLElement* musicContainer = xmlDocument->NewElement("MusicAssets");
  rootElement->InsertAfterChild(backgroundTextureAsset, musicContainer);

  tinyxml2::XMLElement* normalTileContainer = xmlDocument->NewElement("NormalTiles");
  rootElement->InsertAfterChild(musicContainer, normalTileContainer);

  tinyxml2::XMLElement* collisionTileContainer = xmlDocument->NewElement("CollisionTiles");
  rootElement->InsertAfterChild(normalTileContainer, collisionTileContainer);

  tinyxml2::XMLElement* normalDecalContainer = xmlDocument->NewElement("NormalDecals");
  rootElement->InsertAfterChild(collisionTileContainer, normalDecalContainer);

  tinyxml2::XMLElement* collisionDecalContainer = xmlDocument->NewElement("CollisionDecals");
  rootElement->InsertAfterChild(normalDecalContainer, collisionDecalContainer);

  tinyxml2::XMLElement* startingPointContainer = xmlDocument->NewElement("StartingPoints");
  rootElement->InsertAfterChild(collisionDecalContainer, startingPointContainer);

  tinyxml2::XMLElement* previousNormalTile = nullptr;
  tinyxml2::XMLElement* previousCollisionTile = nullptr;
  tinyxml2::XMLElement* previousNormalDecal = nullptr;
  tinyxml2::XMLElement* previousCollisionDecal = nullptr;
  tinyxml2::XMLElement* previousStartingPoint = nullptr;

  // Now serialize all the level objects now that the containers have been set up
  for (LevelDesignObject* levelObject : levelObjects)
  {
    switch (levelObject->GetObjectType())
    {
      case LevelDesignObjectType::kNormalTile:
        previousNormalTile = SerializeLevelObject(levelObject, xmlDocument, normalTileContainer, previousNormalTile);
        break;

      case LevelDesignObjectType::kCollisionTile:
        previousCollisionTile = SerializeLevelObject(levelObject, xmlDocument, collisionTileContainer, previousCollisionTile);
        break;

      case LevelDesignObjectType::kNormalDecal:
        previousNormalDecal = SerializeLevelObject(levelObject, xmlDocument, normalDecalContainer, previousNormalDecal);
        break;

      case LevelDesignObjectType::kCollisionDecal:
        previousCollisionDecal = SerializeLevelObject(levelObject, xmlDocument, collisionDecalContainer, previousCollisionDecal);
        break;

      case LevelDesignObjectType::kStartingPosition:
        previousStartingPoint = SerializeLevelObject(levelObject, xmlDocument, startingPointContainer, previousStartingPoint);
        break;
    }
  }

  xmlDocument->SaveFile(GetDataAsset().c_str());
}
Exemplo n.º 14
0
void FB_Frame::OnFileHistory( wxCommandEvent& event ) {
    CreateDocument( m_Config->m_FileHistory->GetHistoryFile(( event.GetId() - wxID_FILE1 ) ) );
}
Exemplo n.º 15
0
void FB_Frame::OnNew( wxCommandEvent& event )
{
    CreateDocument(  );
}