Various work...
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@51 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
5311ac0b6b
commit
144b59f561
15 changed files with 368 additions and 126 deletions
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2009 by Henrik Just
|
||||
* Copyright: 2002-2019 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-05-01)
|
||||
* Version 1.2 (2010-03-12)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -36,7 +36,6 @@ import com.sun.star.container.XNameAccess;
|
|||
import com.sun.star.document.XDocumentInfoSupplier;
|
||||
import com.sun.star.frame.XDesktop;
|
||||
import com.sun.star.lang.XComponent;
|
||||
import com.sun.star.lang.IllegalArgumentException;
|
||||
import com.sun.star.lang.XMultiServiceFactory;
|
||||
import com.sun.star.lang.XServiceInfo;
|
||||
import com.sun.star.lang.XServiceName;
|
||||
|
@ -46,9 +45,9 @@ import com.sun.star.uno.Type;
|
|||
import com.sun.star.uno.UnoRuntime;
|
||||
import com.sun.star.uno.XComponentContext;
|
||||
import com.sun.star.util.XChangesBatch;
|
||||
import com.sun.star.util.XMacroExpander;
|
||||
|
||||
import org.openoffice.da.comp.w2lcommon.helper.DialogBase;
|
||||
import org.openoffice.da.comp.w2lcommon.helper.MacroExpander;
|
||||
import org.openoffice.da.comp.w2lcommon.helper.PropertyHelper;
|
||||
import org.openoffice.da.comp.w2lcommon.helper.XPropertySetHelper;
|
||||
|
||||
|
@ -170,26 +169,6 @@ public abstract class OptionsDialogBase extends DialogBase implements
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
// Some private utility methods
|
||||
|
||||
// Perform macro extansion
|
||||
private String expandMacros(String s) {
|
||||
if (s.startsWith("vnd.sun.star.expand:")) {
|
||||
// The string contains a macro, usually as a result of using %origin% in the registry
|
||||
s = s.substring(20);
|
||||
Object expander = xContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander");
|
||||
XMacroExpander xExpander = (XMacroExpander) UnoRuntime.queryInterface (XMacroExpander.class, expander);
|
||||
try {
|
||||
return xExpander.expandMacros(s);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
// Unknown macro name found, proceed and hope for the best
|
||||
return s;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the template name from the document with ui focus
|
||||
private String getTemplateName() {
|
||||
try {
|
||||
|
@ -419,8 +398,9 @@ public abstract class OptionsDialogBase extends DialogBase implements
|
|||
Object config = xNameAccess.getByName(sConfigNames[i]);
|
||||
XPropertySet xCfgProps = (XPropertySet)
|
||||
UnoRuntime.queryInterface(XPropertySet.class,config);
|
||||
filterData.put("ConfigURL",expandMacros(XPropertySetHelper.getPropertyValueAsString(xCfgProps,"ConfigURL")));
|
||||
filterData.put("TemplateURL",expandMacros(XPropertySetHelper.getPropertyValueAsString(xCfgProps,"TargetTemplateURL")));
|
||||
MacroExpander expander = new MacroExpander(xContext);
|
||||
filterData.put("ConfigURL",expander.expandMacros(XPropertySetHelper.getPropertyValueAsString(xCfgProps,"ConfigURL")));
|
||||
filterData.put("TemplateURL",expander.expandMacros(XPropertySetHelper.getPropertyValueAsString(xCfgProps,"TargetTemplateURL")));
|
||||
XPropertySetHelper.setPropertyValue(xProps,"ConfigName",sConfigNames[i]);
|
||||
bFound = true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* OptionsDialogBase.java
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-03-12)
|
||||
*
|
||||
*/
|
||||
|
||||
package org.openoffice.da.comp.w2lcommon.helper;
|
||||
|
||||
import com.sun.star.lang.IllegalArgumentException;
|
||||
import com.sun.star.uno.UnoRuntime;
|
||||
import com.sun.star.uno.XComponentContext;
|
||||
import com.sun.star.util.XMacroExpander;
|
||||
|
||||
public class MacroExpander {
|
||||
|
||||
private XMacroExpander xExpander;
|
||||
|
||||
/** Convenience wrapper class for the UNO Macro Expander singleton
|
||||
*
|
||||
* @param xContext the UNO component context from which "theMacroExpander" can be created
|
||||
*/
|
||||
public MacroExpander(XComponentContext xContext) {
|
||||
Object expander = xContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander");
|
||||
xExpander = (XMacroExpander) UnoRuntime.queryInterface (XMacroExpander.class, expander);
|
||||
}
|
||||
|
||||
/** Expand macros in a string
|
||||
*
|
||||
* @param s the string
|
||||
* @return the expanded string
|
||||
*/
|
||||
public String expandMacros(String s) {
|
||||
if (xExpander!=null && s.startsWith("vnd.sun.star.expand:")) {
|
||||
// The string contains a macro, usually as a result of using %origin% in the registry
|
||||
s = s.substring(20);
|
||||
try {
|
||||
return xExpander.expandMacros(s);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
// Unknown macro name found, proceed and hope for the best
|
||||
return s;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -401,6 +401,7 @@ public final class ConfigurationDialog
|
|||
// Maybe add some info for Ubuntu users
|
||||
// sudo apt-get install texlive
|
||||
// sudo apt-get install texlive-xetex
|
||||
// sudo apt-get install texlive-latex-extra
|
||||
// sudo apt-get install tex4ht
|
||||
displayAutoConfigInfo(info.toString());
|
||||
changeApplication(xWindow);
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2009 by Henrik Just
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-11-19)
|
||||
* Version 1.2 (2010-03-12)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -34,6 +34,7 @@ import java.net.URISyntaxException;
|
|||
import com.sun.star.beans.PropertyValue;
|
||||
import com.sun.star.beans.XPropertyAccess;
|
||||
import com.sun.star.beans.XPropertySet;
|
||||
import com.sun.star.container.XNameAccess;
|
||||
import com.sun.star.frame.XController;
|
||||
import com.sun.star.frame.XFrame;
|
||||
import com.sun.star.frame.XModel;
|
||||
|
@ -46,6 +47,7 @@ import com.sun.star.ui.dialogs.XExecutableDialog;
|
|||
import com.sun.star.uno.UnoRuntime;
|
||||
import com.sun.star.uno.XComponentContext;
|
||||
|
||||
import org.openoffice.da.comp.w2lcommon.helper.MacroExpander;
|
||||
import org.openoffice.da.comp.w2lcommon.helper.MessageBox;
|
||||
import org.openoffice.da.comp.w2lcommon.helper.PropertyHelper;
|
||||
import org.openoffice.da.comp.w2lcommon.helper.RegistryHelper;
|
||||
|
@ -378,7 +380,16 @@ public final class Writer4LaTeX extends WeakBase
|
|||
case 5: filterData.put("ConfigURL","$(user)/writer2latex.xml");
|
||||
filterData.put("AutoCreate","true"); break;
|
||||
default:
|
||||
loadOption(xProps,filterData,"ConfigName","ConfigURL");
|
||||
// Get the actual URL from the registry
|
||||
String sConfigName = XPropertySetHelper.getPropertyValueAsString(xProps, "ConfigName");
|
||||
|
||||
Object configurations = XPropertySetHelper.getPropertyValue(xProps,"Configurations");
|
||||
XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class,configurations);
|
||||
Object config = xNameAccess.getByName(sConfigName);
|
||||
XPropertySet xCfgProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class,config);
|
||||
|
||||
MacroExpander expander = new MacroExpander(m_xContext);
|
||||
filterData.put("ConfigURL",expander.expandMacros(XPropertySetHelper.getPropertyValueAsString(xCfgProps,"ConfigURL")));
|
||||
}
|
||||
|
||||
// Read the options
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue